package com.ssm.service.impl;

import com.ssm.entity.ElcBlacklist;
import com.ssm.dao.ElcBlacklistDao;
import com.ssm.service.ElcBlacklistService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ElcBlacklist)表服务实现类
 *
 * @author makejava
 * @since 2021-06-01 10:37:07
 */
@Service("elcBlacklistService")
public class ElcBlacklistServiceImpl implements ElcBlacklistService {
    @Resource
    private ElcBlacklistDao elcBlacklistDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ElcBlacklist queryById(Integer id) {
        return this.elcBlacklistDao.queryById(id);
    }

    @Override
    public boolean queryByDetail(String detail) {
        return this.elcBlacklistDao.queryByDetail(detail)==null;
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ElcBlacklist> queryAllByLimit(int offset, int limit) {
        return this.elcBlacklistDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<ElcBlacklist> queryAll(ElcBlacklist elcBlacklist){
        return this.elcBlacklistDao.queryAll(elcBlacklist);
    }

    @Override
    public List<ElcBlacklist> queryAllN() {
        return this.elcBlacklistDao.queryAllN();
    }


    /**
     * 新增数据
     *
     * @param elcBlacklist 实例对象
     * @return 实例对象
     */
    @Override
    public ElcBlacklist insert(ElcBlacklist elcBlacklist) {
        this.elcBlacklistDao.insert(elcBlacklist);
        return elcBlacklist;
    }

    /**
     * 修改数据
     *
     * @param elcBlacklist 实例对象
     * @return 实例对象
     */
    @Override
    public ElcBlacklist update(ElcBlacklist elcBlacklist) {
        this.elcBlacklistDao.update(elcBlacklist);
        return this.queryById(elcBlacklist.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.elcBlacklistDao.deleteById(id) > 0;
    }

    @Override
    public boolean deleteByIds(Integer[] ids) {
       for (Integer id:ids){
           deleteById(id);
       }
       return true;
    }
}
